/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ru.ibrae.mchs.radiation.entities;

import java.io.Serializable;
import java.util.Set;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

/**
 *
 * @author murr
 */
@Entity
@Table(name = "geoobject", uniqueConstraints = {
    @UniqueConstraint(columnNames = {"ID_NP"})})
@NamedQueries({
    @NamedQuery(name = "Geoobject.findAll", query = "SELECT g FROM Geoobject g"),
    @NamedQuery(name = "Geoobject.findByIdNp", query = "SELECT g FROM Geoobject g WHERE g.idNp = :idNp"),
    @NamedQuery(name = "Geoobject.findByTipNp", query = "SELECT g FROM Geoobject g WHERE g.tipNp = :tipNp"),
    @NamedQuery(name = "Geoobject.findByNameNp", query = "SELECT g FROM Geoobject g WHERE g.nameNp = :nameNp")})
public class Geoobject implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ID_NP", nullable = false)
    private Integer idNp;
    @Basic(optional = false)
    @Column(name = "TIP_NP", nullable = false, length = 5)
    private String tipNp;
    @Basic(optional = false)
    @Column(name = "NAME_NP", nullable = false, length = 80)
    private String nameNp;
    @OneToMany(mappedBy = "geoobject")
    private Set<Result> resultSet;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "geoobject")
    private Set<CrossZon> crossZonSet;
    @JoinColumn(name = "ID_COMENT", referencedColumnName = "ID_COMENT")
    @ManyToOne
    private Comment comment;
    @JoinColumn(name = "ID_SELSOV", referencedColumnName = "ID_SELSOV")
    @ManyToOne
    private Selsovet selsovet;
    @JoinColumn(name = "ID_POSELEN", referencedColumnName = "ID_POSELEN")
    @ManyToOne
    private GSPos gSPos;
    @JoinColumn(name = "ID_RAJON_O", referencedColumnName = "ID_RAJON_O")
    @ManyToOne
    private RajonOld rajonOld;
    @JoinColumn(name = "ID_RAJON", referencedColumnName = "ID_RAJON")
    @ManyToOne
    private Rajon rajon;
    @JoinColumn(name = "ID_SUBJECT", referencedColumnName = "ID")
    @ManyToOne
    private SubjectRf subjectRf;

    public Geoobject() {
    }

    public Geoobject(Integer idNp) {
        this.idNp = idNp;
    }

    public Geoobject(Integer idNp, String tipNp, String nameNp) {
        this.idNp = idNp;
        this.tipNp = tipNp;
        this.nameNp = nameNp;
    }

    public Integer getIdNp() {
        return idNp;
    }

    public void setIdNp(Integer idNp) {
        this.idNp = idNp;
    }

    public String getTipNp() {
        return tipNp;
    }

    public void setTipNp(String tipNp) {
        this.tipNp = tipNp;
    }

    public String getNameNp() {
        return nameNp;
    }

    public void setNameNp(String nameNp) {
        this.nameNp = nameNp;
    }

    public Set<Result> getResultSet() {
        return resultSet;
    }

    public void setResultSet(Set<Result> resultSet) {
        this.resultSet = resultSet;
    }

    public Set<CrossZon> getCrossZonSet() {
        return crossZonSet;
    }

    public void setCrossZonSet(Set<CrossZon> crossZonSet) {
        this.crossZonSet = crossZonSet;
    }

    public Comment getComment() {
        return comment;
    }

    public void setComment(Comment comment) {
        this.comment = comment;
    }

    public Selsovet getSelsovet() {
        return selsovet;
    }

    public void setSelsovet(Selsovet selsovet) {
        this.selsovet = selsovet;
    }

    public GSPos getGSPos() {
        return gSPos;
    }

    public void setGSPos(GSPos gSPos) {
        this.gSPos = gSPos;
    }

    public RajonOld getRajonOld() {
        return rajonOld;
    }

    public void setRajonOld(RajonOld rajonOld) {
        this.rajonOld = rajonOld;
    }

    public Rajon getRajon() {
        return rajon;
    }

    public void setRajon(Rajon rajon) {
        this.rajon = rajon;
    }

    public SubjectRf getSubjectRf() {
        return subjectRf;
    }

    public void setSubjectRf(SubjectRf subjectRf) {
        this.subjectRf = subjectRf;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idNp != null ? idNp.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Geoobject)) {
            return false;
        }
        Geoobject other = (Geoobject) object;
        if ((this.idNp == null && other.idNp != null) || (this.idNp != null && !this.idNp.equals(other.idNp))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "JPAtest.entities.Geoobject[idNp=" + idNp + "]";
    }

}
